<?php

include_once('ConnectionManager.php');

function loadImagesByID($imageID) {
    $query = "SELECT * FROM IMAGE WHERE IMG_ID = $imageID";
    ConnectionManager::getInstance()->setQuery($query);
    ConnectionManager::getInstance()->query();
    return ConnectionManager::getInstance()->fetchArray();
}

function loadImagesByDishID($dishId) {
    $query = "SELECT * FROM IMAGE WHERE DISH_ID = " . $dishId;
    ConnectionManager::getInstance()->setQuery($query);
    return ConnectionManager::getInstance()->query();
}

function insertImage($dishId, $fileName) {
    $query = "INSERT INTO IMAGE (DISH_ID, IMG_PATH) VALUES ($dishId, '$fileName')";
    ConnectionManager::getInstance()->setQuery($query);
    $result = ConnectionManager::getInstance()->query();
    return $result;
}

function updateImage($imgID, $fileName) {
    $query = "UPDATE IMAGE SET IMG_PATH = '$fileName' WHERE IMG_ID = $imgID";
    ConnectionManager::getInstance()->setQuery($query);
    $result = ConnectionManager::getInstance()->query();
    return $result;
}

function removeImageInfo($imageId) {
    $query = "DELETE FROM IMAGE WHERE IMG_ID = $imageId";
    ConnectionManager::getInstance()->setQuery($query);
    ConnectionManager::getInstance()->query();
}



?>